<?php


namespace app\common\model;

class Agreement extends BaseModel
{
    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 获取协议列表
     * @return \think\Collection|\think\Model[]
     */
    public function getAgreementList(){
        return $this->select();
    }

    /**
     * 获取协议详情
     * @return Agreement
     */
    public function getAgreementDetail()
    {
        $id = request()->param('id');
        return $this->field('name,content')->where('id',$id)->find();
    }

    /**
     * 更新协议
     * @return bool
     */
    public function updateAgreement(){
        $param = request()->param();
        return $this->allowField(true)->save($param,['id'=>$param['id']]);
    }

    public function deleteOneAgreement()
    {
        $id = request()->param('id');
        if($id){
            return $this->where('id',$id)->delete();
        }
    }
}